package com.lebang.configuration.thread;

import com.lebang.component.RedisClient;
import com.lebang.configuration.SpringContextHolder;
import com.lebang.service.mongodb.IAppLogMongodb;

/**
 * @Author: hwq
 * @Date: 2019/7/30 11:12
 * @Version 1.0
 */
public class LogThread extends Thread {

    private static IAppLogMongodb appLogMongodb = SpringContextHolder.getBean(IAppLogMongodb.class);
    private static RedisClient redisClient = SpringContextHolder.getBean(RedisClient.class);

//    @Override
//    public void run() {
//        while (true) {
//            try {
//                long size = redisClient.llen(Constant.LOG_QUEUE);
//                if (size > 0) {
//                    LbbAppLog log = JSON.parseObject(redisClient.rpop(Constant.LOG_QUEUE), LbbAppLog.class);
//                    if(log!=null){
//                        appLogMongodb.save(log);
//                    }
//                    Thread.sleep(500);
//                } else {
//                    Thread.sleep(3000);
//                }
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }
//    }
}
